package models
{
	import com.pamakids.models.ResultVO;

	import mx.collections.ArrayCollection;

	import controllers.API;

	public class TextureManager
	{
		public function TextureManager()
		{
		}

		public static function refresh():void
		{
			updating=false;
			end=false;
			page = 1;
			textureGroupAC=new ArrayCollection();
			getTextureList();
		}

		private static const PAGESIZE:int = 6;

		private static var page:int = 1;
		private static var updating:Boolean;
		private static var end:Boolean;

		public static function getTextureList():void
		{
			if(updating||end)
				return;
			updating=true;
			API.instance.getTeacherTexures(textureCB,page,PAGESIZE);
		}

		private static function textureCB(o:ResultVO):void
		{
			updating=false;
			if(o.status)
			{
				var arr:Array = o.results as Array;
				if(arr&&arr.length)
				{
					if(arr.length!=PAGESIZE)
						end=true;
					page++;
					textureGroupAC.addAll(new ArrayCollection(arr));
				}else
				{
					end=true;
				}

//				listHeight=Math.ceil(textureGroupAC.length / 3) * itemGAP;
			}else
			{

			}
		}

		[Bindable]
		public static var textureGroupAC:ArrayCollection = new ArrayCollection();

		private static var itemGAP:Number = 310;

//		public static var listHeight:Number;
	}
}

